import React from 'react';
import ReactDOM from 'react-dom';
import { legacy_createStore as createStore, applyMiddleware } from 'redux'
import { Provider } from 'react-redux'
import createSagaMiddleware from 'redux-saga'
import App from './App';

import '@css/reset.css';
import 'antd/dist/antd.min.css';
import { rootReducers } from './redux/reducers';
import rootSaga from './redux/sagas';

const sagaMiddleware = createSagaMiddleware()
// 将redux-saga中间件加入到redux中
const store = createStore(rootReducers, {}, applyMiddleware(sagaMiddleware))
// 动态的运行saga，注意 sagaMiddleware.run(rootSaga) 只能在applyMiddleware(sagaMiddleware)之后进行
sagaMiddleware.run(rootSaga)
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
